package com.hxzy.service.impl;

import com.hxzy.mapper.MyBatisBaseDao;
import com.hxzy.service.CommonService;

import java.io.Serializable;

/**
 * 类说明
 *
 * @author admin
 * @date 2021-09-01
 */
public class CommonServiceImpl<Model, PK extends Serializable> implements CommonService<Model,PK> {

    //多态
    private MyBatisBaseDao  myBatisBaseDao;

    /**
     * 预留set方法，让子类赋值
     * @param myBatisBaseDao
     */
    public void setMyBatisBaseDao(MyBatisBaseDao myBatisBaseDao) {
        this.myBatisBaseDao = myBatisBaseDao;
    }

    @Override
    public int deleteByPrimaryKey(PK id) {

        return this.myBatisBaseDao.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Model record) {
        return this.myBatisBaseDao.insert(record);
    }

    @Override
    public int insertSelective(Model record) {
        return this.myBatisBaseDao.insertSelective(record);
    }

    @Override
    public Model selectByPrimaryKey(PK id) {
        return (Model) this.myBatisBaseDao.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Model record) {
        return this.myBatisBaseDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Model record) {
        return this.myBatisBaseDao.updateByPrimaryKey(record);
    }
}
